/* Exercise 5.34
   ejer5_34.c */
#include <stdio.h>

/* function prototypes */
long power( int base, int exponent );

/* function main begins program execution */
int main( void )
{
    int a, b;

    printf("Enter the base: ");
    scanf("%d", &a);
    printf("Enter the exponent: ");
    scanf("%d", &b);

    printf("The power is %ld\n", power(a, b));
	return 0; /* indicate that program ended successfully */
} /* end function main */

/* This funcions returns a number powered by another number */
long power( int base, int exponent )
{
    if ( exponent == 1 )
        return base;
    else
        return base * power(base, exponent - 1 );
}
